#pragma once
#define _CRT_SECURE_NO_WARNINGS 1

#include<stdbool.h>
#include<assert.h>
#include<string>
#include<iostream>
using namespace std;

namespace cr  
{


	class my_string
	{
		//friend ostream& operator<<(ostream& out, const my_string& s);
	public:
		typedef char* iterator;
		typedef const char* const_iterator;
		my_string(const char* arr = "");
		my_string(const my_string& tmp);
		void swap(my_string& s);
		my_string& operator=(my_string tmp);
		~my_string();
		int size() const;
		int capacity() const;
		char& operator[](size_t i);
		const char& operator[](size_t i) const;
		iterator begin();
		iterator end();
		const_iterator begin()const;
		const_iterator end()const;
		void push_back(char p);
		void append(const char* p);
		void reserve(size_t n);
		void operator+=(const char* p);
		void operator+=(char p);
		void operator+=(cr::my_string& s);
		void insert(size_t pos, char p);
		void insert(size_t pos, const char* p);
		void erase(size_t pos, size_t len=npos);
		bool operator<(const my_string& s) const;
		bool operator>(const my_string& s) const;
		bool operator==(const my_string& s) const;
		bool operator>=(const my_string& s) const;
		bool operator<=(const my_string& s) const;
		bool operator!=(const my_string& s) const;
		void clear();
		void resize(int n,char p = 0);
		size_t find(char p,int pos=0);
		size_t find(const char* p,int pos=0);
		my_string substr(size_t pos,size_t len = npos);


	private:
		char* _arr;
		size_t _size;
		size_t _capacity;
	public:
		const static size_t npos;

	};
	ostream& operator<<(ostream& out, const my_string& s);
	istream& operator>>(istream& in, my_string& s);


}